package com.u2b.dispatcher;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;



import com.u2b.business.status.StatusService;
import com.u2b.global.utils.Constants;


public class StatusDispatcher
{
    private final StatusService statusService;

    public StatusDispatcher()
    {

        statusService = new StatusService();

    }

    public Object dispatcer(String action, HashMap<String, Object> initValues, HttpServletRequest request)
    {
        Object obj = null;
        if ("add_1".equals(action))
        {
            String[] textFormNames = new String[]
            { "owner", "extra_message", "latitude", "longitude" };
            obj = statusService.addStatus_1(textFormNames, request);

        }
        else if ("add_2".equals(action))
        {
            String[] textFormNames = new String[]
            { "owner", "extra_message", "latitude", "longitude" };
            obj = statusService.addStatus_2(textFormNames, request);

        }
        else if ("list_statuses".equals(action))
        {
            // String[] textFormNames = new String[] { "page", "latitude",
            // "longitude","uid" };
            obj = statusService.getStatusList(initValues);

        }
        //这个部分应该是属于消息推送框架的,但是如果添加额外的对象的话,传递的参数往往会变得复杂,我该怎么做呢?
        else if ("comment".equals(action))
        {
            String[] names = new String[]
            { "sid", "uid", "comment_content", "refrence_mid" };
            obj = statusService.commentThis(initValues);

        }
        else if ("list_comments".equals(action))
        {
            String sid_s = request.getParameter("sid");
            int sid = Integer.valueOf(sid_s);
            obj = statusService.getDetailedMessage(sid);

        }
        return obj;
    }

}
